//
//  BMSetting.m
//  IntelligentSunglasses
//
//  Created by bosma on 14-4-24.
//  Copyright (c) 2014年 cn.com.bosma. All rights reserved.
//

#import "BMSetting.h"

@interface BMSetting ()

@end

@implementation BMSetting

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title =@"设置";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    setTitleArr = @[@[@"用户注销",@"修改密码"],@[@"检查更新",@"app评分",@"应用简介",@"常见问题"]];
    
}

#pragma mark - UItableViewData Delegate

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 2;
    }else{
        return 4;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"setCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    if (indexPath.section == 0) {
        cell.textLabel.text = setTitleArr[0][indexPath.row];
    }else if(indexPath.section == 1){
        cell.textLabel.text = setTitleArr[1][indexPath.row];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.section) {
        case 0:
        {
            switch (indexPath.row) {
                case 0:
                {
                    NSLog(@"用户注销");
                }
                    break;
                case 1:
                {
                    NSLog(@"修改密码");
                }
                    break;
                    
                default:
                    break;
            }
            
        }
            break;
            
        case 1:
        {
            switch (indexPath.row) {
                case 0:
                {
                    NSLog(@"检查更新");
                }
                    break;
                case 1:
                {
                    //软件评分  @"488033535"
                    NSString *str = [NSString stringWithFormat: @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@", @"488033535"];
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
                    NSLog(@"app评分");
                    
                }
                    break;
                case 2:
                {
                    NSLog(@"应用简介");
                }
                    break;
                case 3:
                {
                    NSLog(@"常见问题");
                }
                    break;
                    
                default:
                    break;
            }
            
        }
            break;
            
        default:
            break;
    }

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
